﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace LineFocus.Nikcron.Common
{
    public class Randomizer
    {
        private const string AlphaNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        private const string Numeric = "0123456789";
        /// <summary>
        /// Get Random String
        /// </summary>
        /// <param name="Length"></param>
        /// <returns></returns>
        public static String GetString(int Length)
        {
            var chars = AlphaNumeric;
            var random = new Random();
            var result = new string(
                Enumerable.Repeat(chars, Length)
                          .Select(s => s[random.Next(s.Length)])
                          .ToArray());
            return result;
        }
        /// <summary>
        /// Get Random Number with Prefix
        /// </summary>
        /// <param name="Prefix"></param>
        /// <param name="Length"></param>
        /// <returns></returns>
        public static String GetRandomNumber(string Prefix, int Length=6)
        {
            var chars = Numeric;
            var random = new Random();
            var result = new string(
                Enumerable.Repeat(chars, Length)
                          .Select(s => s[random.Next(s.Length)])
                          .ToArray());
            return Prefix + result;
        }
    }
}